Skip to content

fix: fix optimize-locales-plugin not "tree shaking" react-aria package#10023

Merged
reidbarber merged 1 commit into
adobe:mainfrom
wojtekmaj:fix-plugin
May 11, 2026
Merged

fix: fix optimize-locales-plugin not "tree shaking" react-aria package#10023
reidbarber merged 1 commit into
adobe:mainfrom
wojtekmaj:fix-plugin

Conversation

@wojtekmaj
Copy link
Copy Markdown
Contributor

Closes #10022

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Monkey patch any project using optimize-locales-plugin with the same patch. Observe:

Before:

wojciech.maj@MacBook-Pro proj % yarn build
vite v8.0.5 building client environment for production...
✓ 3047 modules transformed.
computing gzip size...
dist/index.html                  0.91 kB │ gzip:   0.45 kB
dist/assets/index-DmZq51SN.js  477.35 kB │ gzip: 154.79 kB

✓ built in 317ms

After:

wojciech.maj@MacBook-Pro proj % yarn build
vite v8.0.5 building client environment for production...
✓ 2503 modules transformed.
computing gzip size...
dist/index.html                  0.91 kB │ gzip:   0.45 kB
dist/assets/index-D_7D3FJe.js  472.42 kB │ gzip: 151.82 kB

✓ built in 233ms

4.93 KB savings just like that!

🧢 Your Project:

Copilot AI review requested due to automatic review settings May 6, 2026 21:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Expands the locales optimization path filter to include the react-aria package, fixing cases where the optimize-locales tooling wasn’t applied (and thus preventing expected tree-shaking / bundle reduction).

Changes:

  • Extend the resolver’s dependency.sourcePath regex to match react-aria.
  • Extend the Vite/Rollup unplugin resolveId regex to match react-aria.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/dev/parcel-resolver-optimize-locales/LocalesResolver.js Updates source path matching so Parcel resolver also applies to react-aria.
packages/dev/optimize-locales-plugin/LocalesPlugin.js Updates plugin resolution filtering so the unplugin applies to react-aria.

},
resolve({specifier, dependency, config}) {
if (!Array.isArray(config) || !/[/\\](@react-stately|@react-aria|@react-spectrum|react-aria-components)[/\\]/.test(dependency.sourcePath)) {
if (!Array.isArray(config) || !/[/\\](@react-stately|@react-aria|@react-spectrum|react-aria|react-aria-components)[/\\]/.test(dependency.sourcePath)) {
name: 'locales-plugin',
resolveId(specifier, sourcePath, options) {
if (!/[/\\](@react-stately|@react-aria|@react-spectrum|react-aria-components)[/\\]/.test(sourcePath) || options?.ssr) {
if (!/[/\\](@react-stately|@react-aria|@react-spectrum|react-aria|react-aria-components)[/\\]/.test(sourcePath) || options?.ssr) {
Copy link
Copy Markdown
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble reproducing, as mentioned here #10022 (comment)

but this does look correct

snowystinger
snowystinger previously approved these changes May 11, 2026
Copy link
Copy Markdown
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested by going to our example app and running build before and after this change.

@snowystinger
Copy link
Copy Markdown
Member

Ah, looks like there was a merge conflict, you'll want to resolve it by choosing your changes and then running yarn format

@wojtekmaj
Copy link
Copy Markdown
Contributor Author

@snowystinger Here ya go! Congrats on oxfmt migration.

@reidbarber reidbarber added this pull request to the merge queue May 11, 2026
Merged via the queue into adobe:main with commit b3ff30e May 11, 2026
28 checks passed
@wojtekmaj
Copy link
Copy Markdown
Contributor Author

That got me thinking, should the package version be bumped manually?

@wojtekmaj wojtekmaj deleted the fix-plugin branch May 11, 2026 17:23
@yihuiliao yihuiliao added the no testing Does not require manual testing during testing session label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no testing Does not require manual testing during testing session ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

longPressMessage does not respect @react-aria/optimize-locales-plugin settings

5 participants